import 'viewerjs/dist/viewer.css'
import VueViewer from 'v-viewer'
import Vue from 'vue'
Vue.use(VueViewer)
import App from './App'
import router from './router'
import store from './store/'
import Print from 'vue-print-nb'
import CodeEditor from 'bin-code-editor';
import 'bin-code-editor/lib/styles/index.css';
Vue.use(Print);
Vue.use(CodeEditor);
// 'development',use package;'production':use cdn;
import ElementUI from 'element-ui'
Vue.use(ElementUI, { size: 'mini'});
import('element-ui/lib/theme-chalk/index.css')

import $ from 'jquery'
Vue.prototype.$ = $;

import axios from 'axios'
Vue.prototype.$axios = axios;

// import './components/iconSvg' // iconSvg
import '@/icons' // 图标

import '@/permission' // permission control

// import '@/mockjs' // mock数据    删除mockjs引入，解决mockjs对下载时responseType的影响

import cytoscape from 'cytoscape';
Vue.prototype.$cytoscape = cytoscape;

// 图表
import echarts from 'echarts'
Vue.prototype.$echarts = echarts

import moment from 'moment'
Vue.prototype.$moment = moment

// 打印
// import Print from 'vue-print-nb'
// Vue.use(Print);

Vue.config.productionTip = false;
Vue.prototype.$destroyCacheKeys = {};
//绑定自动销毁缓存方法
Vue.prototype.$destroyCacheKey = function () {
  try {
    let cache = this.$vnode.parent.componentInstance.cache
    let keys = this.$vnode.parent.componentInstance.keys
    console.log("key",keys)
    console.log("cache",cache)
    console.log("$destroyCacheKeys",this.$destroyCacheKeys)
    if (keys.length > 0){
      let deteleKeys = []
      for (let i = 0; i < keys.length; i++) {
        let flag = false;
        for (const path in this.$destroyCacheKeys) {
          if (keys[i].indexOf(this.$destroyCacheKeys[path]) != -1){
            flag = true;
          }
        }
        if (!flag){
          try{
            cache[keys[i]].componentInstance.$destroy()
          }catch (e) {
            console.log(e)
          }
          delete cache[keys[i]]
          deteleKeys.push(i)
        }
      }
      for (let i = 0; i < deteleKeys.length; i++) {
        keys.splice(deteleKeys[i], 1);
      }
    }
  }catch (e) {
    console.log(e)
  }

}
new Vue({
  router,
  store,
  render: h => h(App),
}).$mount('#app')
